using UnityEngine;

public class TowerBossAttack1:EnemyAttack
{
    //物品
    public GameObject cdObj;
    public GameObject effObj;
    //cd时间
    public float cdTimer = 1f;
    public bool canCd = true;
    //伤害cd
    public float damageTimer = 0.1f;

    //能否攻击
    public bool canAttack = true;

    private void Update()
    {
        //计算cd
        UpdateCDTimer();
    }
    //计算cd
    public void UpdateCDTimer()
    {
        if(canCd)
        {
            cdTimer-=Time.deltaTime;
            if(cdTimer<=0)
            {
                canCd=false;
                effObj.SetActive(true);
                cdObj.SetActive(false);
            }
        }
        else
        {
            damageTimer-=Time.deltaTime;
        }
    }

    private void OnTriggerStay2D(Collider2D collision)
    {
        if (canAttack == false) return;
        if (collision.GetComponent<Player>() != null)
        {
            if (damageTimer <= 0)
            {
                AttackPlayer();
                canAttack = true;
            }
        }
    }
}